package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.TypeMapper;
import com.lune.job.pojo.ResPageBean;
import com.lune.job.pojo.Type;
import com.lune.job.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type> implements ITypeService {

    @Autowired
    private TypeMapper typeMapper;

    /**
     * 分页查询类型
     * @param currentPage
     * @param size
     * @param type
     * @return
     */
    @Override
    public ResPageBean getAllTypeByPage(Integer currentPage, Integer size, Type type) {
        Page<Type> page = new Page<>(currentPage, size);
        IPage<Type> typeIPage= typeMapper.getAllTypeByPage(page,type);
        ResPageBean resPageBean = new ResPageBean(typeIPage.getTotal(), typeIPage.getPages(), typeIPage.getRecords());

        return resPageBean;
    }
}
